Conversation
|
Thanks for your pull request, @marler8997! We are looking forward to reviewing it, and you should be hearing from a maintainer soon. Some tips to help speed things up:
Bear in mind that large or tricky changes may require multiple rounds of review and revision. Please see CONTRIBUTING.md for more information. Bugzilla referencesYour PR doesn't reference any Bugzilla issue. If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog. |
b54b716 to
d017a30
Compare
d017a30 to
6218580
Compare
|
Hmmm, this is going to make testing more difficult. Now that the JSON file contains semantic data, it's contents are different for each platform, and also changes depending on the order that files were passed to the compiler. |
6218580 to
ca63c46
Compare
|
1 quick sanity check: seeing whether on a large project, adding -Xf=file
slows down compilation (or consumes more memory ?) than without. Because
each function declaeation (+other things) gets serialized. If so, we'd need
a syntax like -X=imports,versions,libs to control what gets exported.
in any case, its a less gacky version than -v
…On Jan 20, 2018 9:07 AM, "Jonathan Marler" ***@***.***> wrote:
Hmmm, this is going to make testing more difficult. Now that the JSON file
contains semantic data, it's contents are different for each platform, and
also changes depending on the order that files were passed to the compiler.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#7757 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ACF9YOAI8HLQmmMtatlOxF82YoAQpIdkks5tMh1bgaJpZM4RlfaI>
.
|
|
Based on the code, I don't anticipate json code generation having a big performance impact. However, if it does then filtering can always be added later as an after thought. Maybe: |
479722a to
9a297d6
Compare
I checked on ae ( |
BTW, if we ever do need to add that, it should probably be a list of things to include rather than a list of things to exclude. Tools that would make use of this option will know exactly what they want, so any information that's added later will not be useful to them. |
|
yeah good point |
9a297d6 to
a90c983
Compare
|
@WalterBright We may want to try to give this PR some attention early on because if this PR along with the changes to rdmd don't get in before the next release, then we will have an extra use case to handle, namely, the case where you have a compiler that supports |
| { | ||
| objectStart(); | ||
| if(m.md) | ||
| property("name", m.md.toChars()); |
There was a problem hiding this comment.
how about:
property("name", m.md ? m.md.toChars() : "");
to make each entry have each field? (and update https://github.com/dlang/tools/pull/292/files#diff-e6f94050037e7c9a64684829764b1f0bR832 accordingly)
There was a problem hiding this comment.
I was following the convention established here (https://github.com/dlang/dmd/pull/7757/files/a90c983d6e436e46dde3b1ee07fdd280ea1396e7#diff-1d73c979f233c43e47fb88fac32c21b3L475)
I don't really see much difference whether or not there is an empty name or no name at all, but following the existing convention seems the better choice.
| objectStart(); | ||
| if(m.md) | ||
| property("name", m.md.toChars()); | ||
| property("file", m.srcfile.toChars()); |
There was a problem hiding this comment.
how about absolutePath ( m.srcfile.toChars() ) so that if rdmd is called from a different directory, it'll still work?
There was a problem hiding this comment.
hmmmm, interesting thought. I'd have to think about that one. This is mimicking the current functionality from the verbose output, but maybe it can be improved. I'll come back to this.
There was a problem hiding this comment.
NOTE: "contentImports" appears to use absolutePath (i tried with -J. and import("foo.txt") ), so I would make sense to be consistent. I suggest using absolutePath for file as well (and wherever else it makes sense)
There was a problem hiding this comment.
I believe that would be changing behavior though...we could end up with a regression if we change the behavior.
There was a problem hiding this comment.
well, that info wasn't in json output before... so it's one of those gray area things.
one option is to allow configuring json output (as I suggested somewhere else), which is OK if we have good (easily extensible) way to customize, eg:
-Xf=file -Xopt=abspaths,imports,-functions
each option has a corresponding - flag to negate it, just like you did for -i=core,-std
There was a problem hiding this comment.
Now that I think about it, there might be a bug in the current design. If you build with rdmd, and then you change directories and build again, then all the relative module filenames will be incorrect. It might just force you to do a rebuild, but that's no good. We could fix this using absolute paths, or we could save off the original CWD that rdmd was using when it first performed the build.
There was a problem hiding this comment.
There should be a test for that in the rdmd test suite, FWIW.
There was a problem hiding this comment.
there may even be corner cases where it picks up wrong file eg:
ls
main.d
fun.d
temp/fun.d // slightly different version main.d
rdmd main.d
cd temp
rdmd ../main.d
=> can it get confused and get the wrong fun.d?
Here's a good compromise:
add a CWD field, and when rdmd reads a path (any path) call buildPath(json.CWD, json.path) (does the right thing w absolute paths)
and allow for:
rdmd main.d
cd temp
rdmd ../main.d => should reuse cache and not rebuild
There was a problem hiding this comment.
but we should definitely make behavior consistent between contentImports and modules.file:
import("fun.txt") should not get auto-transformed in an absolute path either.
There was a problem hiding this comment.
I'm thinking that the JSON file saves the CWD in the new buildInfo object.
src/dmd/json.d
Outdated
| arrayStart(); | ||
| foreach (file; m.contentImportedFiles) | ||
| { | ||
| value(file); |
There was a problem hiding this comment.
BUG! missing separaters in generated JSON
"contentImports" : [
"/tmp/myfile.txt""/tmp/myfile.txt"
]
7bb732c to
8be0d2d
Compare
| { | ||
| "kind" : "buildInfo", | ||
| "binary" : "../generated/linux/release/64/dmd", | ||
| "version" : "v2.078.1-beta.1-494-g479722a-dirty", |
There was a problem hiding this comment.
You probably want to have frontendVersion here too.
There was a problem hiding this comment.
Also you can't check for neither the version nor binary in the testsuite - they are supposed to change ;-)
There was a problem hiding this comment.
they are "grepped" out along with some other types of lines (see json-postscript.sh). I thought keeping an example in the actual expected results didn't hurt though.
wilzbach
left a comment
There was a problem hiding this comment.
Do we really need to generate the JSON file?
It makes future updates of the JSON file more difficult as the line numbers on the diff won't reflect the ones in the generated script. Also it's easy to screw up the JSON generation. How about moving the things that are platform-specific into a different test?
4f8dfc7 to
3e18689
Compare
|
@andralex has determined that adding policies to |
Sorry, I don't think we finished the previous conversation. Why not use |
|
That would work "functionally". The only drawback is that the two files won't be in the same order that was generated from DMD, which would look odd. The order of the fields as generated by DMD makes sense, i.e. name first, followed by other identifying properties, followed by more verbose fields such as large objects. Would be nice to keep it in the same order. I refuse to accept that sanitizing a JSON file while preserving the original object field order is an insurmountable task in D :) |
IMHO that's fine, considering the circumstances, but it's not up to me to decide.
Certainly not insurmountable, but it may be worth keeping our feet on the ground in this case. It's just a test case file that hopefully won't be edited / looked at often at all, so maybe just go for the simplest solution. |
Yes I see your point. I'll concede this and go with your solution. Be prepared for a large |
3e18689 to
2bc4cf9
Compare
|
Ok I caved, the JSON sanitizer uses |
2bc4cf9 to
41aaf97
Compare
|
Ping. Trying to get this PR finalized and integrated so we have some time before the 2.079 release to modify rdmd to use it (dlang/tools#292). |
|
Restarted Jenkins |
wilzbach
left a comment
There was a problem hiding this comment.
Looks good, but please add a short changelog entry.
| *fileNode = JSONValue(normalizeFile(fileNode.str)); | ||
| newModules.put(JSONValue(semanticModule)); | ||
| } | ||
| *modulesArrayPtr = newModules.data; |
There was a problem hiding this comment.
Holy moly, is std.json ugly. We really need to put a warning in this module to prevent people from using it.
| @@ -1,930 +1,976 @@ | |||
| [ | |||
There was a problem hiding this comment.
FYI for the future: typically automatically run commands are separated in different commits, s.t. reviewers don't have to look at them too closely. In this case, GH hides the file anyways.
| else if (name == "offset") | ||
| removeNumber(&value.object[name]); | ||
| else | ||
| sanitizeSyntaxNode(value.object[name]); |
There was a problem hiding this comment.
Not a fan of this (I know that's how the status quo is).
Ideally this would be configurable via a flag, s.t. special platform-specific, short tests which test that the deco is correctly set in the json output can be added, but that's definitely not something which shouldn't block this PR.
There was a problem hiding this comment.
Ok, I added a --keep-deco flag that can be used by tests in the future.
1471901 to
dc7fb7a
Compare
|
Added the changelog |
dc7fb7a to
24d9d18
Compare
wilzbach
left a comment
There was a problem hiding this comment.
Thanks a lot for putting all the hard work into this!
I'm going to merge this now to unblock your work on rdmd - could you do a quick follow up to cover the uncovered output of the imported files? Thanks!
| foreach (file; m.contentImportedFiles) | ||
| { | ||
| item(file); | ||
| } |
| } | ||
| else | ||
| { | ||
| writeln("Error: too many command line arguments"); |
This PR is based on recommendation from @WalterBright (#7746 (comment)). In order for
rdmdto support single-invocation, we need a way to get the information it currently gets from "verbose output", but without losing error messages and other stdout messages. Walter recommended rdmd switch to using the JSON file that dmd generates. Currently the JSON file is missing most of the information that rdmd requires, so this PR is adding that information to it.Most of the information needed by rdmd is "semantic data" whereas the JSON file seems to contain "syntax data". Because of this, I've added the "semantic data" to the end of the JSON file in it's own object called
semantics. Here's a list of the new additions and the current status:import("somefile")) (ADDED)Along with semantic data, there is some build information that rdmd uses. I've put this in the beginning of the JSON file in an object named "buildInfo". It contains the following:
-libis used (ADDED)